package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "order_info", schema = "springboot", catalog = "")
public class OrderInfo {
    private int orderId;//订单编号
    private String orderName;//订单单号
    private int orderState;//订单状态
    private Timestamp orderTime;//下单时间
    private Date deliveryTime;//最晚发货时间
    private BigDecimal receivableOrder;//已回款金额
    private Integer orderPayment;//付款方式
    private Integer businesId3;//对应机会id
    private Integer quotationId;//报价单id
    private Integer consigneeId;//收货联系人id
   // private String customerId;//对应客户id
    private String orderNoteinfo;//备注信息
    private Collection<Ctschemes> ctschemesByOrderId;
    private Collection<Deliveryplan> deliveryplansByOrderId;
    private Collection<Exchange> exchangesByOrderId;
    private Contract contractByContractId;//对应合同
    private List<Orderdetails> orderdetailsByOrderId;//订单详情
    //private Collection<Receivingcontact> receivingcontactsByOrderId;//(收货人)关系错乱
    private Collection<Returnorder> returnordersByOrderId;
    private Emp empId;//员工信息
    private BigDecimal orderTotal;//订单总金额
    private String orderTheme;//主题
    private Customer customerByCustomId;//客户信息order_cusid  customerByCustomId
    private String outboundType;//出库方式
    private String customerName;//签约人
    private Integer orderApproverid;//order_approverid审批id
    private Integer orderAppstate;//order_appstate//审批状态

    @Id
    @Column(name = "order_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    @Basic
    @Column(name = "order_name")
    public String getOrderName() {
        return orderName;
    }

    public void setOrderName(String orderName) {
        this.orderName = orderName;
    }

    @Basic
    @Column(name = "order_state")
    public int getOrderState() {
        return orderState;
    }

    public void setOrderState(int orderState) {
        this.orderState = orderState;
    }

    @Basic
    @Column(name = "order_time")
    public Timestamp getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(Timestamp orderTime) {
        this.orderTime = orderTime;
    }

    @Basic
    @Column(name = "delivery_time")
    public Date getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(Date deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    @Basic
    @Column(name = "receivable_order")
    public BigDecimal getReceivableOrder() {
        return receivableOrder;
    }

    public void setReceivableOrder(BigDecimal receivableOrder) {
        this.receivableOrder = receivableOrder;
    }

    @Basic
    @Column(name = "order_payment")
    public Integer getOrderPayment() {
        return orderPayment;
    }

    public void setOrderPayment(Integer orderPayment) {
        this.orderPayment = orderPayment;
    }

    @Basic
    @Column(name = "busines_id3")
    public Integer getBusinesId3() {
        return businesId3;
    }

    public void setBusinesId3(Integer businesId3) {
        this.businesId3 = businesId3;
    }

    @Basic
    @Column(name = "quotation_id")
    public Integer getQuotationId() {
        return quotationId;
    }

    public void setQuotationId(Integer quotationId) {
        this.quotationId = quotationId;
    }

    @Basic
    @Column(name = "consignee_id")
    public Integer getConsigneeId() {
        return consigneeId;
    }

    public void setConsigneeId(Integer consigneeId) {
        this.consigneeId = consigneeId;
    }

    @Basic
    @Column(name = "order_noteinfo")
    public String getOrderNoteinfo() {
        return orderNoteinfo;
    }

    public void setOrderNoteinfo(String orderNoteinfo) {
        this.orderNoteinfo = orderNoteinfo;
    }

    @ManyToOne
    @JoinColumn(name = "emp_id", referencedColumnName = "employees_id")
    public Emp getEmpId() {
        return empId;
    }

    public void setEmpId(Emp empId) {
        this.empId = empId;
    }

    @Basic
    @Column(name = "order_total")
    public BigDecimal getOrderTotal() {
        return orderTotal;
    }

    public void setOrderTotal(BigDecimal orderTotal) {
        this.orderTotal = orderTotal;
    }

    @Basic
    @Column(name = "order_theme")
    public String getOrderTheme() {
        return orderTheme;
    }

    public void setOrderTheme(String orderTheme) {
        this.orderTheme = orderTheme;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        OrderInfo orderInfo = (OrderInfo) o;
        return orderId == orderInfo.orderId &&
                orderState == orderInfo.orderState &&
                Objects.equals(orderName, orderInfo.orderName) &&
                Objects.equals(orderTime, orderInfo.orderTime) &&
                Objects.equals(deliveryTime, orderInfo.deliveryTime) &&
                Objects.equals(receivableOrder, orderInfo.receivableOrder) &&
                Objects.equals(orderPayment, orderInfo.orderPayment) &&
                Objects.equals(businesId3, orderInfo.businesId3) &&
                Objects.equals(quotationId, orderInfo.quotationId) &&
                Objects.equals(consigneeId, orderInfo.consigneeId) &&
                Objects.equals(customerName, orderInfo.customerName) &&
                Objects.equals(orderNoteinfo, orderInfo.orderNoteinfo);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orderId, orderName, orderState, orderTime, deliveryTime, receivableOrder, orderPayment, businesId3, quotationId, orderNoteinfo,orderTotal,orderTheme,customerName);
    }

    @OneToMany(mappedBy = "orderInfoByOrderId")
    public Collection<Ctschemes> getCtschemesByOrderId() {
        return ctschemesByOrderId;
    }

    public void setCtschemesByOrderId(Collection<Ctschemes> ctschemesByOrderId) {
        this.ctschemesByOrderId = ctschemesByOrderId;
    }

    @OneToMany(mappedBy = "orderInfoByOrderId")
    public Collection<Deliveryplan> getDeliveryplansByOrderId() {
        return deliveryplansByOrderId;
    }

    public void setDeliveryplansByOrderId(Collection<Deliveryplan> deliveryplansByOrderId) {
        this.deliveryplansByOrderId = deliveryplansByOrderId;
    }

    @OneToMany(mappedBy = "orderInfoByOrderId")
    public Collection<Exchange> getExchangesByOrderId() {
        return exchangesByOrderId;
    }

    public void setExchangesByOrderId(Collection<Exchange> exchangesByOrderId) {
        this.exchangesByOrderId = exchangesByOrderId;
    }

    @ManyToOne
    @JoinColumn(name = "contract_id", referencedColumnName = "contract_id")
    public Contract getContractByContractId() {
        return contractByContractId;
    }

    public void setContractByContractId(Contract contractByContractId) {
        this.contractByContractId = contractByContractId;
    }

    @OneToMany(mappedBy = "orderInfo")//orderInfoByOrderId
    public List<Orderdetails> getOrderdetailsByOrderId() {
        return orderdetailsByOrderId;
    }

    public void setOrderdetailsByOrderId(List<Orderdetails> orderdetailsByOrderId) {
        this.orderdetailsByOrderId = orderdetailsByOrderId;
    }

    /*@OneToMany(mappedBy = "orderInfoByOrderId")
    public Collection<Receivingcontact> getReceivingcontactsByOrderId() {
        return receivingcontactsByOrderId;
    }

    public void setReceivingcontactsByOrderId(Collection<Receivingcontact> receivingcontactsByOrderId) {
        this.receivingcontactsByOrderId = receivingcontactsByOrderId;
    }*/

    @OneToMany(mappedBy = "orderInfoByOrderId")
    public Collection<Returnorder> getReturnordersByOrderId() {
        return returnordersByOrderId;
    }

    public void setReturnordersByOrderId(Collection<Returnorder> returnordersByOrderId) {
        this.returnordersByOrderId = returnordersByOrderId;
    }


    @ManyToOne
    @JoinColumn(name = "tpl_id", referencedColumnName = "custom_id")
    public Customer getCustomerByCustomId() {
        return customerByCustomId;
    }

    public void setCustomerByCustomId(Customer customerByCustomId) {
        this.customerByCustomId = customerByCustomId;
    }



    @Basic
    @Column(name = "outbound_type")
    public String getOutboundType() {
        return outboundType;
    }

    public void setOutboundType(String outboundType) {
        this.outboundType = outboundType;
    }


    @Basic
    @Column(name = "customer_name")
    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    @Basic
    @Column(name = "order_approverid")
    public Integer getOrderApproverid() {
        return orderApproverid;
    }

    public void setOrderApproverid(Integer orderApproverid) {
        this.orderApproverid = orderApproverid;
    }

    @Basic
    @Column(name = "order_appstate")
    public Integer getOrderAppstate() {
        return orderAppstate;
    }

    public void setOrderAppstate(Integer orderAppstate) {
        this.orderAppstate = orderAppstate;
    }
}
